<?php require_once('../Connections/locale.php'); ?>
<?php
mysql_select_db($database_locale, $locale);
$query_tipologie = "SELECT * FROM tipologie";
$tipologie = mysql_query($query_tipologie, $locale) or die(mysql_error());
$row_tipologie = mysql_fetch_assoc($tipologie);
$totalRows_tipologie = mysql_num_rows($tipologie);

mysql_select_db($database_locale, $locale);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../style.css" rel="stylesheet" type="text/css">
</head>

<body>
<fieldset>
<legend>Elenco Tipologie</legend>

<table border="1" id="datatable">
  <tr>
    <td><div align="center"><strong>ID</strong></div></td>
    <td><div align="center"><strong>Descrizione Tipologia</strong></div></td>
    <td><div align="center"><strong><a href="inserimento_tipologia.php"><img src="../images/page.gif" alt="Nuova Tipologia" width="18" height="18" border="0"></a></strong></div></td>
    <td><div align="center"></div></td>
  </tr>
  <?php do { ?>
  <tr>
    <td><?php echo $row_tipologie['id_tipologia']; ?></td>
    <td><?php echo $row_tipologie['descrizione_tipologia']; ?></td>
    <td><a href="modifica_tipologia.php?id_tipologia=<?php echo $row_tipologie['id_tipologia']; ?>"><img src="../images/modifica.png" width="16" height="16" border="0"></a></td>
    <td><?php 
	$query_legami_abbonati = "SELECT * FROM abbonati_riviste WHERE id_tipologia = ".$row_tipologie['id_tipologia'];
	$legami_abbonati = mysql_query($query_legami_abbonati, $locale) or die(mysql_error());
	$row_legami_abbonati = mysql_fetch_assoc($legami_abbonati);
	$totalRows_legami_abbonati = mysql_num_rows($legami_abbonati);
		
	
	if ($totalRows_legami_abbonati == 0) { // Show if recordset empty ?>
        <img src="../images/elimina.png" width="16" height="16">
        <?php } // Show if recordset empty ?></td>
  </tr>
  <?php } while ($row_tipologie = mysql_fetch_assoc($tipologie)); ?>
</table>
</fieldset>
</body>
</html>
<?php
mysql_free_result($tipologie);

mysql_free_result($legami_abbonati);
?>
